***This do-file creates Figure 3 of the paper
**Curtis RESTAT
**Change to directory where data and code were downloaded
**cd 

use cbp_st_figure3,clear
do cbp_dataclean_figure3.do
rename fipstate state
collapse (sum) emp (first) postxeast post enint,by(naics east year)
egen intrank=rank(enint),by(year east)
gen cat="low" if inlist(intrank,1,2,3,4,5,6,7,8,9)
replace cat="high" if inlist(intrank,14,15,16,17,18,19,20,21)
replace cat="mid" if cat==""


collapse (sum) emp ,by(cat east year)

tostring east,replace
gen groupgeo=cat+east
encode groupgeo, gen(intreg)
xtset intreg year
gen lagemp=l.emp
gen emp98t=emp if year==1998
egen emp98=max(emp98t),by(intreg)
drop emp98t
gen perchange=(emp-emp98)/emp98

keep perchange east cat intreg year
reshape wide east cat perchange,i(year) j(intreg)
gen highdiff=perchange2-perchange1
gen middiff=perchange6-perchange5
gen lowdiff=perchange4-perchange3
twoway line highdiff middiff lowdiff year,play(fig3edit.grec)
